﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using EZCRS.HCMS.Bll.presentinfo;

namespace EZCRS.HCMS.myajax
{
    public class Present:MainBase
    {
        #region 分类相关
        /// <summary>
        /// 保存或修改分类
        /// </summary>
        /// <param name="sname"></param>
        /// <param name="sid"></param>
        /// <returns></returns>
        /// 
        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string savesort(string sname, string sid)
        {
            int gid = base.BasGroupId;
            int pid = base.BasHotelId;

            BllAdmPresentSort sort = new BllAdmPresentSort();
            if (sort.savesort(sname, Convert.ToInt32(sid), gid, pid,base.LanguageId))
                return "1";
            else
                return "0";
        }

        /// <summary>
        /// 删除分类
        /// </summary>
        /// <param name="sidlist"></param>
        /// <returns></returns>
        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string delsort(string sidlist)
        {
            BllAdmPresentSort sort = new BllAdmPresentSort();
            if (sort.delsort(sidlist))
                return "1";
            else
                return "";
        }

        /// <summary>
        /// 保存分类排序
        /// </summary>
        /// <param name="sidlist"></param>
        /// <returns></returns>
        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string saverank(string sidlist)
        {
            BllAdmPresentSort sort = new BllAdmPresentSort();
            if (sort.saverank(sidlist))
                return "1";
            else
                return "0";
        }

        /// <summary>
        /// 返回所有分类
        /// </summary>
        /// <returns></returns>
        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string sortall()
        {
            int gid = base.BasGroupId;
            int pid = base.BasHotelId;

            BllAdmPresentSort sort = new BllAdmPresentSort();
            DataTable dt = sort.allsort(gid, pid,base.LanguageId);

            StringBuilder sb = new StringBuilder();
            int row = 0;
            sb.Append("<table border=\"0\" id=\"tlist\" cellpadding=\"1\" cellspacing=\"1\" width=\"100%\"><tr class=\"title1\" height=\"26\"><td width=\"50\" style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrNumb+"</td><td  style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrName+"</td><td width=\"50\" style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrRank+"</td><td width=\"50\" style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrModify+"</td><td width=\"50\" style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrDel+"</td></tr>");
            foreach (DataRow dr in dt.Rows)
            {
                row++;
                sb.Append("<tr");
                if (row % 2 == 0)
                {
                    sb.Append(" class='line-odd'");
                }
                else
                {
                    sb.Append(" class='line-even'");
                }
                sb.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                sb.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\"");
                sb.Append(">");
                
                sb.Append("<td align=\"center\">");
                sb.Append(dr["sid"].ToString());
                sb.Append("</td>");
                sb.Append("<td align=\"center\">");
                sb.Append(dr["sname"].ToString());
                sb.Append("</td>");

                sb.Append("<td style=\"text-align:center\">");

                if (row != 1)
                {
                    if (row != dt.Rows.Count)
                        sb.Append("<img src=\"../../image/uparrow.png\"  style=\"cursor:hand\" onclick=\"javascript:goUp(this,2);\"> <img src=\"../../image/downarrow.png\"  style=\"cursor:hand\" onclick=\"javascript:goDown(this,2);\">");
                    else
                        sb.Append("<img src=\"../../image/uparrow.png\"  style=\"cursor:hand;margin-right:14px;\" onclick=\"javascript:goUp(this,2);\">");
                }
                else
                    sb.Append("<img src=\"../../image/downarrow.png\"  style=\"cursor:hand;margin-left:14px;\" onclick=\"javascript:goDown(this,2);\">");

                
                
                sb.Append("</td>");
                sb.Append("<td><div align=\"center\">");
                sb.Append("<img src=\"../../image/modify.gif\" border=\"0\" style=\"cursor:hand\" onclick=\"javascript:modisort(this);\">");
                sb.Append("</div></td>");
                sb.Append("<td><div align=\"center\">");
                sb.Append("<img src=\"../../image/delete.gif\" border=\"0\" style=\"cursor:hand\" onclick=\"javascript:jsdelsort(this);\">");
                sb.Append("</div></td>");
                sb.Append("</tr>");
            }
            sb.Append("</table>");
            return sb.ToString();
        }
        
        
        
        #endregion
    }
}
